//===============================================================================
// Microsoft Architecture Strategy Team
// LitwareHR - SaaS Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace LitwareHR.Recruiting.Contract
{
    [DataContract, Serializable]
    public class Position
    {
        private Guid _id;
        private Guid _tenantId;
        private List<Field> _fields;

        public Position(Guid id, List<Field> fields)
        {
            _id = id;
            _fields = fields;
        }

        [DataMember]
        public Guid Id
        {
            get { return _id; }
            set { _id = value; }
        }

        [DataMember]
        public Guid TenantId
        {
            get { return _tenantId; }
            set { _tenantId = value; }
        }

        [DataMember]
        public List<Field> Fields
        {
            get { return _fields; }
            set { _fields = value; }
        }

        public string GetFieldValue(string name)
        {
            Field field = Fields.Find(new Predicate<Field>(delegate(Field dto)
            {
                return dto.Name.Equals(name);
            }));
            string value = string.Empty;
            if (field != null)
            {
                value = field.Value;
            }
            return value;
        }
    }
}